﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;


namespace PictureBoard4.Shape
{
    /// <summary>
    /// 直线
    /// </summary>

    public class Line : Shape
    {
        public Point StartPoint { get; set; }
        public Point EndPoint { get; set; }
        #region 重写父类方法
        public override void Add(Point p)
        {
            if (StartPoint == EndPoint)
                StartPoint = p;
            else
                EndPoint = p;
        }
        public override bool Draw(System.Drawing.Graphics g)
        {
            g.DrawLine(new Pen(Tool.SColor, Tool.SWidth), this.StartPoint, this.EndPoint);
            return true;
        }
        public override bool GetBound(ref Point StartPoint, ref Point EndPoint)
        {
            StartPoint = this.StartPoint;
            EndPoint = this.EndPoint;
            return true;
        }
        public override void Move(Point point)
        {
            if (point.X != 0)
            {
                Point TempStartPoint = StartPoint;
                Point TempEndPoint = EndPoint;

                StartPoint = new Point(TempStartPoint.X + point.X, TempStartPoint.Y + point.Y);
                EndPoint = new Point(TempEndPoint.X + point.X, TempEndPoint.Y + point.Y);
            }

        }
        #endregion
    }
}
